package com.mobile.liuyi_s.orderlunch;

import android.app.Application;

import com.mobile.liuyi_s.orderlunch.entity.MyUser;
import com.mobile.liuyi_s.orderlunch.entity.Order;

import java.util.List;

import cn.bmob.v3.Bmob;

/**
 * Created by liuyi_s on 2017/7/27 16:02.
 * Email：liuyi_s@foxmail.com
 */

public class MyApplication extends Application implements Thread.UncaughtExceptionHandler{

    private MyUser currUser = new MyUser();
    private Order currOrder = new Order();
    private boolean isOrdered;
    private List<Order> orderList50;
    private List<Order> orderList51;
    private List<Order> orderList52;
    private List<Order> orderList53;
    private List<Order> orderList54;
    public static double VersionCode = 1.0;

    public List<Order> getOrderList51() {
        return orderList51;
    }

    public void setOrderList51(List<Order> orderList51) {
        this.orderList51 = orderList51;
    }

    public List<Order> getOrderList52() {
        return orderList52;
    }

    public void setOrderList52(List<Order> orderList52) {
        this.orderList52 = orderList52;
    }

    public List<Order> getOrderList53() {
        return orderList53;
    }

    public void setOrderList53(List<Order> orderList53) {
        this.orderList53 = orderList53;
    }

    public List<Order> getOrderList54() {
        return orderList54;
    }

    public void setOrderList54(List<Order> orderList54) {
        this.orderList54 = orderList54;
    }

    public List<Order> getOrderList50() {
        return orderList50;
    }

    public void setOrderList50(List<Order> orderList50) {
        this.orderList50 = orderList50;
    }
//    private int orderNum50;
//    private int orderNum51;
//    private int orderNum52;
//    private int orderNum53;
//    private int orderNum54;
//
//    public int getOrderNum50() {
//        return orderNum50;
//    }
//
//    public void setOrderNum50(int orderNum50) {
//        this.orderNum50 = orderNum50;
//    }
//
//    public int getOrderNum51() {
//        return orderNum51;
//    }
//
//    public void setOrderNum51(int orderNum51) {
//        this.orderNum51 = orderNum51;
//    }
//
//    public int getOrderNum52() {
//        return orderNum52;
//    }
//
//    public void setOrderNum52(int orderNum52) {
//        this.orderNum52 = orderNum52;
//    }
//
//    public int getOrderNum53() {
//        return orderNum53;
//    }
//
//    public void setOrderNum53(int orderNum53) {
//        this.orderNum53 = orderNum53;
//    }
//
//    public int getOrderNum54() {
//        return orderNum54;
//    }
//
//    public void setOrderNum54(int orderNum54) {
//        this.orderNum54 = orderNum54;
//    }

    @Override
    public void onCreate() {
        super.onCreate();
        Bmob.initialize(this, "900d001fbe6be900902ffb476ae12aea");
    }


    public MyUser getCurrUser() {
        return currUser;
    }

    public Order getCurrOrder() {
        return currOrder;
    }

    public void userLogin(MyUser user) {
        currUser.setUsername(user.getUsername());
        currUser.setUserGroup(user.getUserGroup());
    }

    public void orderCheck(Order order) {
        currOrder.setOrderYear(order.getOrderYear());
        currOrder.setOrderMonth(order.getOrderMonth());
        currOrder.setOrderDay(order.getOrderDay());
    }

    public boolean getIsOrdered() {
        return isOrdered;
    }

    public void setOrdered(boolean ordered) {
        isOrdered = ordered;
    }

    @Override
    public void uncaughtException(Thread thread, Throwable throwable) {
        //当Application因内存不足被释放（但是应用本身未被kill）后kill进程并重启应用
        android.os.Process.killProcess(android.os.Process.myPid());
        System.exit(0);
    }
}
